package com.poorstu.manager.impl;
import java.util.Date;
import java.util.List;
import com.poorstu.dao.AdminDao;
import com.poorstu.manager.AdminMeg;
import com.poorstu.model.LeaseMod;
import com.poorstu.model.RoleMod;

public class AdminMegImpl implements AdminMeg{
	
	private AdminDao adminDao;

	

	public void setAdminDao(AdminDao adminDao) {
		this.adminDao = adminDao;
	}
	
	
	public boolean addRole(String rolename) {
//		RoleMod role=new RoleMod();		
//		role.setRolename(rolename);
//		role.setRoleastatus("1");
//		
//		adminDao.AddRole(role);
		return true;
		
	}

//c查询出role表所有字段，显示在changerole.jsp  页面
	public RoleMod changeRole(int roleid) {
		RoleMod rolemod=new RoleMod(); 
		rolemod=adminDao.changeRole(roleid);

		return rolemod;
	}


	public int deleteRole(int roleid[]) {
		
		int d=adminDao.deleteRole(roleid);
		if(d==1)
		{
		return 1;
		}
		else return 0;
	}


	public int roleChged(int roleid,String rolename,String roleStatus ) {
	    int a =0;
		RoleMod role=new RoleMod();
//		role.setRoleid(roleid);
//		role.setRolename(rolename);
//		role.setRoleastatus(roleStatus);
		try{
		  adminDao.roleChged(role);
		  a=1;
	  }
		catch(Exception e){
		  e.getMessage();
	  }
		return a;
	}
//////////////////  公告管理////

	public int leaseAdd(int alluserid, String leasename, String leasecontent) {
		  int a=0;
		LeaseMod lease=new LeaseMod();
//		lease.setLeasename(leasename);
//		lease.setLeacontent(leasecontent);
//	   // Date time=new Date();		
//		lease.setLeatime(new Date());
		//lease.setLogins(alluserid);
		try{
		adminDao.leaseAdd(lease);
		a=1;
		}
		catch(Exception e){
		
		}
		return a;
	}


	public List<LeaseMod> leaseMag() {
		
		List<LeaseMod> leaseList=adminDao.leaseMag();
		if(leaseList.size()<=0){
		return null;
		}
		return leaseList;
	}


	public int leaseDelete(int[] leaseid) {
			
			int d=adminDao.deleteRole(leaseid);
			if(d==1)
			{
			return 1;
			}
			else return 0;
		}
	
public LeaseMod getLeaseById(int leaseId) {
		
		LeaseMod leaseMod=	adminDao.selLeaseById(leaseId);
		return leaseMod;
		
	}


	public int leaseChange(int leaseId, String leaseName, String leaseContent) {
		  
		int a=0;
		try{
		LeaseMod leaseMod=new LeaseMod();
		  // leaseMod.setLeaseId(leaseId)
		   leaseMod.setLeaseName(leaseName);
		   leaseMod.setLeaContent(leaseContent);
		   leaseMod.setLeaTime(new Date());
		   adminDao.changeLease(leaseMod);
		   a=1;
		}catch(Exception e){
			e.getMessage();
		}
		return a;
	}
	
	
	}
	
	
	


